﻿<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
                xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
                version="1.0"
                exclude-result-prefixes="xsl msxsl ddwrt"
                xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
                xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
                xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:SharePoint="Microsoft.SharePoint.WebControls"
                xmlns:ddwrt2="urn:frontpage:internal">

  <xsl:template match="FieldRef[@FieldType='TableCheckField']" mode="header" ddwrt:dvt_mode="header">
    <th class="ms-vh2" nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)">
    <script type="text/javascript">
      function GetUserName(fieldValue)
      {
        try
        {
          var fieldValues = fieldValue.split(',');
          var screenValue = "";
          for (var valIndex in fieldValues)
          {
            var trimmedValue = fieldValues[valIndex].replace(/^\s+|\s+$/g,"");
            if (trimmedValue != "" &amp;&amp; 
                typeof(trimmedValue.split('|')[3]) != "undefined")
              screenValue += (fieldValues[valIndex].split('|')[3].replace("~","\\")) + ", ";
          }
          
          if (screenValue.length > 0)
            screenValue = screenValue.substring(0, screenValue.length - 2);
            
          document.write(screenValue);
        }
        catch (e)
        {
          document.write("None");
        }
      }
    </script>
        <xsl:call-template name="dvt_headerfield">
        <xsl:with-param name="fieldname">
          <xsl:value-of select="@Name" />
        </xsl:with-param>
        <xsl:with-param name="fieldtitle">
          <xsl:value-of select="@DisplayName" />
        </xsl:with-param>
        <xsl:with-param name="displayname">
          <xsl:value-of select="@DisplayName" />
        </xsl:with-param>
        <xsl:with-param name="fieldtype">
          <xsl:value-of select="@FieldType" />
        </xsl:with-param>
      </xsl:call-template>
    </th>
  </xsl:template>

  <xsl:template match="FieldRef[@FieldType='TableCheckField']" mode="Text_body">
    <xsl:param name="thisNode" select="." />
    <xsl:param name="fieldValue" select="$thisNode/@*[name()=current()/@Name]"/>
    <script type="text/javascript">
      GetUserName("<xsl:value-of select='translate($fieldValue, "\", "~")'/>");
    </script>
  </xsl:template>
</xsl:stylesheet>
